**This document generates variables and displays the commands for Figures 1, 3, 10, A.1, and A.2.  Also, this document generates variables for the annual average troop size that are used in Tables 1 and 2**
**For Figures 5, 6, 7, 8, and 9, as well as Tables 1, 2, please see "FPA_Military_Statecraft_Figures_Tables_2. For the OLS regressions in the appendix, please see "FPA_Military_Statecraft_OLS"**

** Import MME Data**
import excel FPA_Military_Statecraft_MMEs.xlsx, firstrow clear

** Generate Variables**
* Total MMEs for Each Major Power *
by Ex_Year, sort: egen Ex_Count_China= count(Ex_Type) if Country_A=="China" | Country_B=="China" | Country_C=="China" | Country_D=="China" | Country_E=="China" | Country_F=="China"| Country_G=="China"
replace Ex_Count_China=0 if Ex_Count_China==. & Ex_Year < 2002
by Ex_Year, sort: egen Ex_Count_Russia= count(Ex_Type) if Country_A=="Soviet Union" | Country_A=="Russia" | Country_B=="Russia" | Country_C=="Russia" | Country_D=="Russia"| Country_E=="Russia"| Country_F=="Russia" | Country_G=="Russia"
by Ex_Year, sort: egen Ex_Count_USA= count(Ex_Type) if Country_A=="USA" | Country_B=="USA" | Country_C=="USA" | Country_D=="USA" | Country_E=="USA"| Country_F=="USA"| Country_G=="USA"
by Ex_Year, sort: egen Ex_Count_India= count(Ex_Type) if Country_A=="India" | Country_B=="India" | Country_C=="India" | Country_D=="India"| Country_E=="India"| Country_F=="India"| Country_G=="India"
replace Ex_Count_India=0 if Ex_Year<2002
replace Ex_Count_India=1 if Ex_Year==1994
by Ex_Year, sort: egen Ex_Count_Germany= count(Ex_Type) if Country_A=="Germany" | Country_B=="Germany" | Country_C=="Germany" | Country_D=="Germany"| Country_E=="Germany" | Country_G=="Germany" | Country_F=="Germany" | Country_A=="West Germany" | Country_B=="West Germany" | Country_C=="West Germany" | Country_D=="West Germany"| Country_E=="West Germany"
by Ex_Year, sort: egen Ex_Count_France= count(Ex_Type) if Country_A=="France" | Country_B=="France" | Country_C=="France" | Country_D=="France"| Country_E=="France" | Country_F=="France" | Country_G=="France"
by Ex_Year, sort: egen Ex_Count_UK= count(Ex_Type) if Country_A=="UK" | Country_B=="UK" | Country_C=="UK" | Country_D=="UK"| Country_E=="UK" | Country_F=="UK" | Country_G=="UK"
generate Ex_China=1 if Country_A=="China" | Country_B=="China" | Country_C=="China" | Country_D=="China" | Country_E=="China" | Country_F=="China"| Country_G=="China"
generate Ex_Russia=1 if Country_A=="Soviet Union" | Country_A=="Russia" | Country_B=="Russia" | Country_C=="Russia" | Country_D=="Russia"| Country_E=="Russia"| Country_F=="Russia" | Country_G=="Russia"
generate Ex_USA=1 if Country_A=="USA" | Country_B=="USA" | Country_C=="USA" | Country_D=="USA" | Country_E=="USA"| Country_F=="USA"| Country_G=="USA"
generate Ex_India=1 if Country_A=="India" | Country_B=="India" | Country_C=="India" | Country_D=="India"| Country_E=="India"| Country_F=="India"| Country_G=="India"
generate Ex_Germany=1 if Country_A=="Germany" | Country_B=="Germany" | Country_C=="Germany" | Country_D=="Germany"| Country_E=="Germany" | Country_G=="Germany" | Country_F=="Germany" | Country_A=="West Germany" | Country_B=="West Germany" | Country_C=="West Germany" | Country_D=="West Germany"| Country_E=="West Germany"
generate Ex_France=1 if Country_A=="France" | Country_B=="France" | Country_C=="France" | Country_D=="France"| Country_E=="France" | Country_F=="France" | Country_G=="France"
generate Ex_UK=1 if Country_A=="UK" | Country_B=="UK" | Country_C=="UK" | Country_D=="UK"| Country_E=="UK" | Country_F=="UK" | Country_G=="UK"

* For Each Exercise Type and Categories *
by Ex_Year, sort: egen Ex_Type_Det_Count= count(Ex_Type) if Ex_Type=="Deterrence/Rehearsal"
by Ex_Year, sort: egen Ex_Type_Rehearsal_Count= count(Ex_Type) if Ex_Type=="Rehearsal"
by Ex_Year, sort: egen Ex_Type_Traditional_Count= count(Ex_Type) if Ex_Type=="Rehearsal" | Ex_Type=="Deterrence/Rehearsal"
by Ex_Year, sort: egen Ex_Type_Recruitment_Count= count(Ex_Type) if Ex_Type=="Recruitment"
by Ex_Year, sort: egen Ex_Type_BPC_Role_Forming_Count= count(Ex_Type) if Ex_Type=="Role-Forming/Building Partner Capacity"
by Ex_Year, sort: egen Ex_Type_Trust_Developing_Count= count(Ex_Type) if Ex_Type=="Trust Developing"
by Ex_Year, sort: egen Ex_Type_Shaping_Count= count(Ex_Type) if Ex_Type=="Role-Forming/Building Partner Capacity" | Ex_Type=="Recruitment" | Ex_Type=="Trust Developing"
generate Ex_Type_Shaping= 1 if Ex_Type=="Role-Forming/Building Partner Capacity" | Ex_Type=="Recruitment" | Ex_Type=="Trust Developing"
replace Ex_Type_Shaping= 0 if Ex_Type=="Rehearsal" | Ex_Type=="Deterrence/Rehearsal"

* For Allies vs. Non-Allies *
by Ex_Year, sort: egen Ex_Ally_Count= count(Ex_No) if Non_Ally==0
by Ex_Year, sort: egen Ex_NonAlly_Count= count(Ex_No) if Non_Ally==1

* Shaping and Traditional MMEs for Each Major Power *
by Ex_Year, sort: egen Ex_Count_Shaping_China= count(Ex_Type) if Ex_China==1 & Ex_Type_Shaping==1 
by Ex_Year, sort: egen Ex_Count_Shaping_USA= count(Ex_Type) if Ex_USA==1 & Ex_Type_Shaping==1
by Ex_Year, sort: egen Ex_Count_Shaping_UK= count(Ex_Type) if Ex_UK==1 & Ex_Type_Shaping==1
by Ex_Year, sort: egen Ex_Count_Shaping_France= count(Ex_Type) if Ex_France==1 & Ex_Type_Shaping==1
by Ex_Year, sort: egen Ex_Count_Shaping_Germany= count(Ex_Type) if Ex_Germany==1 & Ex_Type_Shaping==1
by Ex_Year, sort: egen Ex_Count_Shaping_Russia= count(Ex_Type) if Ex_Russia==1 & Ex_Type_Shaping==1
by Ex_Year, sort: egen Ex_Count_Shaping_India= count(Ex_Type) if Ex_India==1 & Ex_Type_Shaping==1

by Ex_Year, sort: egen Ex_Count_Traditional_China= count(Ex_Type) if Ex_China==1 & Ex_Type_Shaping==0
by Ex_Year, sort: egen Ex_Count_Traditional_USA= count(Ex_Type) if Ex_USA==1 & Ex_Type_Shaping==0
by Ex_Year, sort: egen Ex_Count_Traditional_UK= count(Ex_Type) if Ex_UK==1 & Ex_Type_Shaping==0
by Ex_Year, sort: egen Ex_Count_Traditional_France= count(Ex_Type) if Ex_France==1 & Ex_Type_Shaping==0
by Ex_Year, sort: egen Ex_Count_Traditional_Germany= count(Ex_Type) if Ex_Germany==1 & Ex_Type_Shaping==0
by Ex_Year, sort: egen Ex_Count_Traditional_Russia= count(Ex_Type) if Ex_Russia==1 & Ex_Type_Shaping==0
by Ex_Year, sort: egen Ex_Count_Traditional_India= count(Ex_Type) if Ex_India==1 & Ex_Type_Shaping==0

** Figures **
* Figure 1: Land-Based MMEs by Exercise Type *
twoway histogram Ex_Year, bin(37) frequency bfcolor(blue) || histogram Ex_Year if Ex_Type_Shaping==0, bfcolor(red) bin(37) frequency xlabel(1980(5)2016) title("Total Land-Based MMEs by Exercise Type") xtitle("Year") legend(order(1 "Shaping" 2 "Traditional"))

* Figure 3: Land-Based MMEs by Partner Type *
twoway histogram Ex_Year, bin(37) frequency bfcolor(orange) || histogram Ex_Year if Non_Ally==0, bfcolor(green) bin(37) frequency xlabel(1980(5)2016) title("Total Land-Based MMEs by Partner Type") xtitle("Year") legend(order(1 "Non-Ally" 2 "Ally"))

* Figure 10: Traditional and Shaping Exercises, 1980-2016 *
line Ex_Type_Traditional_Count Ex_Year, lcolor(red) mcolor(red) xlabel(1980(5)2016) title("Land-Based MMEs by Exercise Type") xtitle("Year") ytitle("Frequency") lwidth(medthick) legend(order(1 "Traditional" 2 "Shaping")) || line Ex_Type_Shaping_Count Ex_Year, lwidth(medthick) mcolor(blue) lcolor(blue)

* Determine Average Exercise Size (for Tables 1 and 2)
by Ex_Year, sort: egen Ave_Troops_Year = mean(Approx_Ex_Size)
by Ex_Year, sort: tab Ave_Troops_Year

* Figures A.1 and A.2 (Appendix)
twoway connected Ex_Count_USA Ex_Year, lcolor(red) mcolor(red) xlabel(1980(5)2016) title("Land-Based Exercises By NATO Major Powers") xtitle("Year") ytitle("Frequency")legend(order(1 "USA" 2 "UK" 3 "France" 4 "Germany"))|| connected Ex_Count_UK Ex_Year, lcolor(blue) mcolor(blue) || connected Ex_Count_France Ex_Year, lcolor(green) mcolor(green) || connected Ex_Count_Germany Ex_Year, lcolor(orange) mcolor(orange)
twoway connected Ex_Count_China Ex_Year, lcolor(red) mcolor(red) xlabel(1980(5)2016) title("Land-Based Exercises By Non-NATO Major Powers") xtitle("Year") ytitle("Frequency")legend(order(1 "China" 2 "Russia" 3 "India"))|| connected Ex_Count_Russia Ex_Year, lcolor(blue) mcolor(blue) || connected Ex_Count_India Ex_Year, lcolor(green) mcolor(green)

** End of file **
clear
